电竞CSGO的【联赛列表】接口,在线接口文档
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
/**
* @API: 联赛列表
* @Website: https://www.feijing88.com
*/
public class CsgoLeague {
public static void main(String[] args) {
try {
String content = getContent();
Respond rsp = JSON.parseObject(content, Respond.class);
System.out.println(rsp.code);
System.out.println(rsp.message);
rsp.getLeagueList().forEach(System.out::println);
} catch (Throwable t) {
t.printStackTrace();
}
}
/**
* 获取API返回内容
* <p>
* Note: 这里为了方便测试我使用了一份本地文件,使用时应替换为真实接口返回内容
*/
private static String getContent() {
try {
StringBuilder builder = new StringBuilder();
List<String> lines = Files.readAllLines(Paths.get("./src/main/resources/CsgoLeague.json"), StandardCharsets.UTF_8);
lines.forEach(builder::append);
return builder.toString();
} catch (Throwable t) {
t.printStackTrace();
return "";
}
}
public static class Respond {
@JSONField(name = "code")
private int code;
@JSONField(name = "message")
private String message;
@JSONField(name = "data")
private List<League> leagueList;
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public List<League> getLeagueList() {
return leagueList;
}
public void setLeagueList(List<League> leagueList) {
this.leagueList = leagueList;
}
}
public static class League {
@JSONField(name = "league_id")
private int leagueId;
@JSONField(name = "logo")
private String logo;
@JSONField(name = "name")
private String name;
@JSONField(name = "country")
private String country;
@JSONField(name = "location")
private String location;
@JSONField(name = "start_time")
private long startTime;
@JSONField(name = "end_time")
private long endTime;
@JSONField(name = "team_ids")
private List<Integer> teamIds;
@JSONField(name = "status")
private int status;
@Override
public String toString() {
return "League{" +
"leagueId=" + leagueId +
", logo='" + logo + '\'' +
", name='" + name + '\'' +
", country='" + country + '\'' +
", location='" + location + '\'' +
", startTime=" + startTime +
", endTime=" + endTime +
", teamIds=" + teamIds +
", status=" + status +
'}';
}
public int getLeagueId() {
return leagueId;
}
public void setLeagueId(int leagueId) {
this.leagueId = leagueId;
}
public String getLogo() {
return logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public long getStartTime() {
return startTime;
}
public void setStartTime(long startTime) {
this.startTime = startTime;
}
public long getEndTime() {
return endTime;
}
public void setEndTime(long endTime) {
this.endTime = endTime;
}
public List<Integer> getTeamIds() {
return teamIds;
}
public void setTeamIds(List<Integer> teamIds) {
this.teamIds = teamIds;
}
public int getStatus() {
return status;
}
public void setStatus(int status) {
this.status = status;
}
}
}
API 返回数据如下(部分):
200
成功
League{leagueId=9866, logo='http://qn.feijing88.com/feijing-home/egame/image/20190514/49cd2c63e3834fa2a92df8f1d02ec390.png', name='DreamHack Open Sevilla 2019', country='Spain', location='Sevilla, Spain', startTime=1576234800000, endTime=1576407600000, teamIds=[], status=2}
League{leagueId=9342, logo='http://qn.feijing88.com/feijing-home/egame/image/20190801/a50756930fbe44b68b35c1e63febfe70.jpg', name='Gamers Club Masters IV', country='Brazil', location='Sorocaba, São Paulo', startTime=1576148400000, endTime=1577012400000, teamIds=[], status=0}
League{leagueId=9253, logo='http://qn.feijing88.com/feijing-home/egame/image/20190624/06280d3da7e640708ff86179eee76ffb.jpg', name='ESL Pro League Season 10 Finals', country='Denmark', location='Odense, Denmark', startTime=1575630000000, endTime=1575802800000, teamIds=[], status=2}
League{leagueId=9868, logo='http://qn.feijing88.com/feijing-home/egame/image/20190514/7190e798f3d84ce2b52902f09dbc2349.png', name='DreamHack Open Winter 2019', country='Sweden', location='Jönköping, Sweden', startTime=1575025200000, endTime=1575198000000, teamIds=[], status=0}
League{leagueId=9240, logo='http://qn.feijing88.com/feijing-home/egame/image/20190711/b340bbdf32554914961b4a1e328a3c9b.png', name='CS:GO Asia Championships 2019', country='China', location='Shanghai, China', startTime=1574334000000, endTime=1574593200000, teamIds=[9425, 5761, 9428], status=2}
League{leagueId=9867, logo='http://qn.feijing88.com/feijing-home/egame/image/20190514/04e44a98f9564a4983568ae8b95bc506.png', name='DreamHack Open Atlanta 2019', country='United States', location='Atlanta, Georgia, USA', startTime=1573815600000, endTime=1573988400000, teamIds=[], status=0}
League{leagueId=9246, logo='http://qn.feijing88.com/feijing-home/egame/image/20190713/7a21b891f3fd493c94c19e17d82d543c.jpg', name='eXTREMESLAND 2019 Asia Finals', country='China', location='Shanghai, China', startTime=1573729200000, endTime=1573988400000, teamIds=[], status=2}
League{leagueId=9307, logo='http://qn.feijing88.com/feijing-home/egame/image/20190627/2f20036ba3a84bbb90815f1acb8c2dbf.jpg', name='BLAST Pro Series Copenhagen 2019', country='Denmark', location='Copenhagen, Denmark', startTime=1572606000000, endTime=1572692400000, teamIds=[1538, 2221, 9204, 9966], status=2}
League{leagueId=9348, logo='http://qn.feijing88.com/feijing-home/egame/image/20190801/aad3efd47ed64a1a922ae1b56dbc3996.png', name='ESL LA League Season 5 Finals', country='Brazil', location='São Paulo', startTime=1572084000000, endTime=1572170400000, teamIds=[], status=2}
League{leagueId=9275, logo='http://qn.feijing88.com/feijing-home/egame/image/20190521/5860289be57d46dc88eaa30bac90bb45.png', name='Logitech G Challenge 2019', country='Mexico', location='Mexico City, Mexico', startTime=1571997600000, endTime=1571997600000, teamIds=[], status=2}
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。